package com.app.internationaltravel.controller;

import com.app.internationaltravel.dto.PhoneCodeDto;
import com.app.internationaltravel.service.intf.SmsService;
import com.app.internationaltravel.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 刘豆豆
 * @date 2022/12/12
 */

@RestController
@RequestMapping("/api/sms/")
@Api(tags = "实现短信的相关操作")
@CrossOrigin //跨域
public class SmsController {
  @Resource
  private SmsService service;

  @ApiOperation(value = "查询全部短信记录", notes = "查询全部短信记录")
  @GetMapping("all.do")
  public R all() {
    return service.all();
  }

  @ApiOperation(value = "发送注册验证码", notes = "发送注册验证码")
  @GetMapping("sendrcode.do")
  public R sendRCode(String phone) {
    return service.sendRegisterCode(phone);
  }

  @ApiOperation(value = "发送登录验证码", notes = "发送登录验证码")
  @GetMapping("sendlcode.do")
  public R sendLCode(String phone) {
    return service.sendLoginCode(phone);
  }

  @ApiOperation(value = "发送密码找回验证码",notes = "发送密码找回验证码")
  @GetMapping("sendfcode.do")
  public R sendFCode(String phone){
    return service.sendFindCode(phone);
  }

  @ApiOperation(value = "校验注册验证码", notes = "校验注册验证码")
  @PostMapping("checkrcode.do")
  public R checkRcode(@RequestBody PhoneCodeDto dto) {
    return service.checkRegiterCode(dto);
  }
}